import {Component,OnDestroy} from '@angular/core';

import { LiveShopHistoryService } from './live.shop.history.service';

import { Util } from '../../../utils/util';
import { Subscription } from 'rxjs';

@Component({
  selector:'live-shop-history',
  templateUrl:'./live.shop.history.html',
  providers:[LiveShopHistoryService]
})

export class LiveShopHistory{

    busy: Subscription;

  liveShopInfo:any;

  // pages data
  vm: any = {
    page: 1,
    table: {
      shops: [],
      count: 0
    }
  };
  constructor(private service:LiveShopHistoryService,private util:Util){

    this.liveShopInfo = this.util.sessionStore().get('liveShopHistory');

    this.getHttp(this.liveShopInfo);
  }

  ngOnDestroy(){
    if(this.busy){
      this.busy.unsubscribe();
    }
  }



  getHttp(liveShopInfo){

    let json = {
      uid:liveShopInfo.uid,
      darenId:liveShopInfo.darenId
    };

    var res = {"code":0,"msg":"成功","data":[{"id":"263817957\u00012017-11-04 00:00:00\u0001263817957","date":"2017-11-04 00:00:00","uid":263817957,"nick":null,"shopName":null,"darenId":263817957,"sellAmount7Days":1117,"sellMoney7Days":33357.0,"productNum7Days":12,"sellAmount30Days":5424,"sellMoney30Days":533690.0,"productNum30Days":105,"viewCount7Days":50415,"praiseCount7Days":65420,"viewCount30Days":223637,"praiseCount30Days":290424},{"id":"263817957\u00012017-11-05 00:00:00\u0001263817957","date":"2017-11-05 00:00:00","uid":263817957,"nick":null,"shopName":null,"darenId":263817957,"sellAmount7Days":1159,"sellMoney7Days":34327.0,"productNum7Days":15,"sellAmount30Days":5466,"sellMoney30Days":534660.0,"productNum30Days":107,"viewCount7Days":85246,"praiseCount7Days":177929,"viewCount30Days":258468,"praiseCount30Days":402933},{"id":"263817957\u00012017-11-06 00:00:00\u0001263817957","date":"2017-11-06 00:00:00","uid":263817957,"nick":null,"shopName":null,"darenId":263817957,"sellAmount7Days":1159,"sellMoney7Days":34327.0,"productNum7Days":15,"sellAmount30Days":5466,"sellMoney30Days":534660.0,"productNum30Days":107,"viewCount7Days":85246,"praiseCount7Days":177929,"viewCount30Days":258468,"praiseCount30Days":402933},{"id":"263817957\u00012017-11-07 00:00:00\u0001263817957","date":"2017-11-07 00:00:00","uid":263817957,"nick":null,"shopName":null,"darenId":263817957,"sellAmount7Days":275,"sellMoney7Days":15565.0,"productNum7Days":9,"sellAmount30Days":5466,"sellMoney30Days":534660.0,"productNum30Days":107,"viewCount7Days":60151,"praiseCount7Days":144822,"viewCount30Days":258468,"praiseCount30Days":402933},{"id":"263817957\u00012017-11-09 00:00:00\u0001263817957","date":"2017-11-09 00:00:00","uid":263817957,"nick":null,"shopName":null,"darenId":263817957,"sellAmount7Days":42,"sellMoney7Days":970.0,"productNum7Days":4,"sellAmount30Days":5466,"sellMoney30Days":534660.0,"productNum30Days":107,"viewCount7Days":34831,"praiseCount7Days":112509,"viewCount30Days":258468,"praiseCount30Days":402933},{"id":"263817957\u00012017-11-11 00:00:00\u0001263817957","date":"2017-11-11 00:00:00","uid":263817957,"nick":null,"shopName":null,"darenId":263817957,"sellAmount7Days":20854,"sellMoney7Days":6408742.0,"productNum7Days":31,"sellAmount30Days":25980,"sellMoney30Days":6872146.0,"productNum30Days":109,"viewCount7Days":179806,"praiseCount7Days":1931958,"viewCount30Days":374337,"praiseCount30Days":2223655},{"id":"263817957\u00012017-11-12 00:00:00\u0001263817957","date":"2017-11-12 00:00:00","uid":263817957,"nick":null,"shopName":null,"darenId":263817957,"sellAmount7Days":20854,"sellMoney7Days":6408742.0,"productNum7Days":31,"sellAmount30Days":25687,"sellMoney30Days":6801441.0,"productNum30Days":88,"viewCount7Days":179806,"praiseCount7Days":1931958,"viewCount30Days":342707,"praiseCount30Days":2190677},{"id":"263817957\u00012017-11-16 00:00:00\u0001263817957","date":"2017-11-16 00:00:00","uid":263817957,"nick":null,"shopName":null,"darenId":263817957,"sellAmount7Days":20854,"sellMoney7Days":6408742.0,"productNum7Days":31,"sellAmount30Days":24080,"sellMoney30Days":6493311.0,"productNum30Days":65,"viewCount7Days":179806,"praiseCount7Days":1931958,"viewCount30Days":315749,"praiseCount30Days":2155109},{"id":"263817957\u00012017-11-17 00:00:00\u0001263817957","date":"2017-11-17 00:00:00","uid":263817957,"nick":null,"shopName":null,"darenId":263817957,"sellAmount7Days":20854,"sellMoney7Days":6408742.0,"productNum7Days":31,"sellAmount30Days":24080,"sellMoney30Days":6493311.0,"productNum30Days":65,"viewCount7Days":179806,"praiseCount7Days":1931958,"viewCount30Days":315749,"praiseCount30Days":2155109},{"id":"263817957\u00012017-11-18 00:00:00\u0001263817957","date":"2017-11-18 00:00:00","uid":263817957,"nick":null,"shopName":null,"darenId":263817957,"sellAmount7Days":20757,"sellMoney7Days":6403390.0,"productNum7Days":28,"sellAmount30Days":24080,"sellMoney30Days":6493311.0,"productNum30Days":65,"viewCount7Days":75305,"praiseCount7Days":606574,"viewCount30Days":315749,"praiseCount30Days":2155109}]};

    setTimeout(()=>{

      this.vm.table.shops = res.data;

      this.vm.table.count = res.data.length;
    },100);

  }

}
